
<div id="page-heading"><input type="button" value="Add Product" style="float: right;" id="admin-add-product"><h1>Product List</h1></div>

<form action="<?php echo site_url('admin/save_product'); ?>" method="post" encrypt-data>
	
	<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
					<tbody><tr>
						<th class="table-header-repeat line-left minwidth-1"><a href="">ID</a>	</th>
						<th class="table-header-repeat line-left minwidth-1"><a href="">Title</a></th>
						<th class="table-header-repeat line-left minwidth-1"><a href="">Category</a></th>
						<th class="table-header-repeat line-left"><a href="">Create Date</a></th>
						<th class="table-header-repeat line-left"><a href="">Edit Date</a></th>
						<th class="table-header-options line-left"><a href="">Options</a></th>
					</tr>
					<?php foreach ($products as $product): ?>
						
					<tr>
						<td><?php echo $product['id'] ?></td>
						<td><?php echo $product['title'] ?></td>
						<td><?php echo $product['category_title'] ?></td>
						<td><?php echo $product['create_date'] ?></td>
						<td><?php echo $product['update_date'] ?></td>
						<td class="options-width">
							<a href="<?php echo site_url('admin/edit_product/'.$product['id']) ?>" title="Edit Product" class="icon-1 info-tooltip"></a>
							<a href="#" title="Delete Product" class="icon-2 info-tooltip product-delete" id="<?php echo $product['id']; ?>"></a>
						</td>
					</tr>
					
					<?php endforeach ?>
					</tbody></table>

</form>
<script type="text/javascript">
$('#admin-add-product').click(function(){
	window.location = '<?php echo site_url('admin/edit_product');?>';
});
$('.product-delete').click(function(e){
	e.preventDefault();
	if(confirm('ต้องการลบข้อมูลใช่หรือไม่?')){
		$.get('/admin/delete_product/'+this.id,function(data){
			alert('ลบข้อมูลเรียบร้อยแล้ว');
			location.reload();
		});
	}
})
</script>